﻿// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)

Shader "GJ/Skin" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SColor ("Second Color", Color) = (1,1,1,1)
    _MainTex ("Main Texture", 2D) = "black" {}
    _ColSpeed("ColSpeed", Range(0, 10)) = 1
    _TexSpeed("TexSpeed", Range(0, 10)) = 1
    _Weight("Weight", Range(-1, 1)) = 0
    // _Range("Range", Range(0.1, 1)) = 0.5
    // [Enum(ON, 0, OFF, 1)] _("Speed", float) = 1
}
SubShader {
    Tags {
        "Queue"="Transparent"
        "IgnoreProjector"="True"
        "RenderType"="Transparent"
    }
    Cull Off Lighting Off ZWrite Off
    Blend SrcAlpha OneMinusSrcAlpha

    Pass {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma target 2.0

        #include "UnityCG.cginc"

        sampler2D _MainTex;
        fixed4 _Color;
        fixed4 _SColor;
        fixed _ColSpeed;
        fixed _TexSpeed;
        fixed _Weight;
        // fixed _Range;

        struct appdata_t {
            float4 vertex : POSITION;
            fixed4 color : COLOR;
            float2 texcoord : TEXCOORD0;
            UNITY_VERTEX_INPUT_INSTANCE_ID
        };

        struct v2f {
            float4 vertex : SV_POSITION;
            fixed4 color : COLOR;
            float2 texcoord : TEXCOORD0;
            UNITY_VERTEX_OUTPUT_STEREO
        };

        float4 _MainTex_ST;

        v2f vert (appdata_t v)
        {
            v2f o;
            float s;
            UNITY_SETUP_INSTANCE_ID(v);
            UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
            o.vertex = UnityObjectToClipPos(v.vertex);
            o.color = v.color;
            s = sin(_TexSpeed * _Time.y) * 0.01f;
            v.texcoord.x = v.texcoord.x + s;
            v.texcoord.y = v.texcoord.y + s;
            o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
            return o;
        }

        fixed4 frag (v2f i) : SV_Target
        {
            float s = abs(sin(_ColSpeed * _Time.y)) + _Weight;
            fixed4 col = lerp(_Color, _SColor, s);
            fixed4 tex = tex2D(_MainTex, i.texcoord);
            col = col * tex;
            return col;
        }
        ENDCG
    }
}

}